/*jslint browser: true, devel: true, bitwise: true, white: true, plusplus: true, nomen:true */
/*global $:true, define:true */

/**
 * @module UI
 */

define(['WID/UI/Widget','WID/UI/Container'],function(Widget,Container) {
"use strict";

/**  
 * Kontener na inne kontrolki, panel może rozkładać kontrolki poziomo lub pionowo.
 * @class Panel
 * @constructor
 */
function Panel(props) {
	props = props||{};
	Container.call(this,props);
	var 
		ntv = this.ntv,
		element = $(ntv),
		bg = props.bgType;
	
	if (props.absolute) {
		ntv.style.position = 'absolute';
		this.setPosition(props.t,props.l,props.r,props.b);
	}
	ntv.setAttribute('class',this.CPANEL);
	
	if (props.type === 'h')	{
		element.addClass(this.HORIZONTAL);
	} else {
		element.addClass(this.VERTICAL);
	}
	
	if (bg) {
		element.addClass(this.CNORMAL);
		if (bg === 'solid') {
			element.addClass(this.CSOLID);
			ntv.style.backgroundColor = props.bgColor||'white';
		} else if (bg === 'glass') {
			element.addClass(this.CGLASS);
		} else if (bg === 'gradient'){
			element.addClass(this.CGRADIENT);
		}
	}
	
} var extend = Object.create(Container.prototype); extend.constructor = Panel;

extend.CPANEL = 'nlPanel';
extend.CNORMAL = 'nlNormalPanel';
extend.CSOLID = 'nlSolidPanel';
extend.CGRADIENT = 'nlGradientPanel';
extend.CGLASS = 'nlGlassPanel';
extend.CVERTICAL = 'nlVPanel';
extend.CHORIZONTAL = 'nlHPanel';

extend.setPos = function(top, left, right, bottom) {
	var ns = this.ntv.style;
	ns.top = top||ns.top;
	ns.left = left||ns.left;
	ns.right = right||ns.right;
	ns.bottom = bottom||ns.bottom;
};

extend.setSize = function(width, height, unit) {
	var ns = this.ntv.style;
	unit = unit||'px';
	ns.width = width+unit;
	ns.height = height+unit;
}; 

Widget.defineProps(extend,{
	width: {
		get: function() {
			return this.ntv.style.width;
		},
		set: function(width) {
			this.ntv.style.width = width;
		}
	},
	
	height: {
		get: function() {
			return this.ntv.style.height;
		},
		set: function(height) {
			this.ntv.style.height = height;
		}
	}
});

Panel.prototype = extend;
return Panel;
});
